<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			class Person {
				name;
				sex;
				birthday;
				constructor(name, sex, birthday) {
					this.name = name;
					this.sex = sex;
					this.birthday = birthday;
				}
				get() { // 获取年龄
					var date = new Date();
					var year = date.getFullYear();

					var birthDate = new Date(this.birthday);
					var birthYear = birthDate.getFullYear();

					return year - birthYear;
				}
			}
			class Human extends Person{
				constructor(name,sex,birthday,skill) {
					super(name,sex,birthday);
				    this.skill = skill;
				}
			}
			var human1 = new Human("张三","男","2001-02-08","游泳");
			console.log(human1);
			console.log("年龄:" + human1.get());
			
			var human2 = new Human("李四","女","2003-02-08","舞蹈");
			console.log(human2);
			console.log("年龄:" + human2.get());
		</script>
	</body>
</html>
